/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.ResultSet;
import pojo.QuanTriPOJO;
import util.MySQLDataAccessHelper;

/**
 *
 * @author NhatHuy
 */
public class QuanTriDAO extends KhachHangDAO {
    /**
     * Phương thức lấy thông tin khách hàng theo tên đăng nhập.
     */
    public static QuanTriPOJO layThongTin(String tenDangNhap){
        QuanTriPOJO qt = new QuanTriPOJO();
        try{
            String sql = "SELECT * FROM KHACHHANG WHERE TenDangNhap='"+tenDangNhap+"'";
            
            MySQLDataAccessHelper helper = new MySQLDataAccessHelper();
            helper.open();
            ResultSet rs = helper.executeQuery(sql);
            while (rs.next()){
                qt.setTenDangNhap(rs.getString("TenDangNhap"));
                qt.setMatKhau(rs.getString("MatKhau"));
                qt.setHoTen(rs.getString("HoTen"));
                qt.setDiaChi(rs.getString("DiaChi"));
                qt.setEmail(rs.getString("Email"));
                qt.setMaLoaiTaiKhoan(rs.getInt("MaLoaiTaiKhoan"));
            }
            helper.close();
        }catch (Exception ex){
            System.out.println(ex.getMessage());
        }
        return qt;
    }   
}
